//twopts.txt - Like basic monst, but this character spends all its time oscillating 
// between two nav points.
// Memory Cells:
//   Cell 0 - Ability. If 1, scythes.
//   Cell 1,2 - Stuff done flag. If both 0, nothing. Otherwise when this is killed, set to 1.
//	 Cell 3 - The nav point the character marches to. If -1, stand still
//   Cell 4 - If 0, this patrols. If 1, stays put.

begincreaturescript;

variables;

short i,target;
short path_a_or_b = 0;
short adjust = 0;
short last_abil;
short did_sighting = 0;

body;

beginstate INIT_STATE;
	last_abil = get_current_tick();
	
	
	set_aggression(ME,10);

		
	break;

beginstate DEAD_STATE;
	
break;

beginstate START_STATE; 

	
	// if I have a target for some reason, go attack it
	if (who_shot_me() >= 0) {
		did_sighting = 1;
		set_foe_target(ME,who_shot_me());
		do_attack();
		set_state(3);
		}
	if (target_ok()) {
		if (dist_to_char(get_target()) <= 16)
			set_state(3);
			else set_foe_target(ME,-1);
		}
	
	if (get_foe_target(ME,8,0)) {

		if (can_see_char(1000)) {
			if ((get_attitude(ME) >= 10) && (did_sighting == 0)) {
				did_sighting = 1;
				if (has_item_equip(376) == FALSE) {
					print_named_str(ME,"stares at you. Then it attacks!");
					if (gf(29,25) == 0) {
						sf(29,25,1);
						begin_talk_mode(30);
						}
						
					}
					else if (get_stat(20) < 10) {
						print_named_str(ME,"looks at your necklace, but you fail to calm it.");
						if (gf(29,23) == 0) {
							sf(29,23,1);
							begin_talk_mode(31);
							}
						}
						else {
							print_named_str(ME,"looks at your necklace. You are able to calm it.");
							set_attitude(1000 + what_group_in(ME),4);
							set_foe_target(ME,-1);
							if (gf(29,24) == 0) {
								sf(29,24,1);
								begin_talk_mode(32);
								}
							end();
							}
				}
			}
			
		do_attack();
		set_state(3);
		}


			if (gf(29,22) == 0) {
				if (dist_to_nav_point(ME,get_memory_cell(3)) >= 3)
					approach_nav_point(ME,get_memory_cell(3),2);	
				}
				else return_to_start(ME,2);


		
	if (am_i_doing_action() == FALSE)
		end_combat_turn();
break;

beginstate 3; // attacking
	if (target_ok() == FALSE)
		set_state(START_STATE);


		
	do_attack();
break;

beginstate TALKING_STATE;

	break;